#ifndef __AURA_PLUS_H__
#define __AURA_PLUS_H__

#define NOTRACE(args...)

#define DBG_PRINTF(args...) \
{ \
    printf (args); \
}


#define PERROR DBG_PRINTF
#define PTRACE NOTRACE
#define PENTRY NOTRACE
#define PLOGEXIT NOTRACE


typedef char                CHAR;
typedef short               SHORT;
typedef int                 INT;
typedef long                LONG;
typedef void                VOID;
typedef unsigned long       SIZE_T;

typedef unsigned char       UCHAR;
typedef unsigned short      USHORT;
typedef unsigned int        UINT;
typedef unsigned long       ULONG;

typedef Aura_Int8           INT8;
typedef Aura_Int16          INT16;
typedef Aura_Int32          INT32;
typedef Aura_Int64          INT64;

typedef Aura_UInt8          UINT8;
typedef Aura_UInt16         UINT16;
typedef Aura_UInt32         UINT32;
typedef Aura_UInt64         UINT64;

typedef UINT32              UInt32;

typedef Aura_Bool           Boolean;

typedef INT                 BOOL;
typedef UINT8               BYTE;

typedef void               *HANDLE;
typedef void               *PVOID;
typedef LONG                LRESULT;

typedef VOID        *LPVOID;
typedef const void*  LPCVOID;
typedef CHAR        *PCHAR,  *LPCHAR;
typedef UCHAR       *PUCHAR, *LPUCHAR;

typedef UINT32       *PULONG;
typedef USHORT      *PUSHORT;

typedef long LONG_PTR, *PLONG_PTR;

typedef unsigned short  WORD;
typedef unsigned long   DWORD;
typedef DWORD          *PDWORD;
typedef const void     *PCVOID;

typedef DWORD          *LPDWORD;

#ifdef __cplusplus
#define INLINE inline
#elif defined(_MSC_VER)
#define INLINE __inline
#elif defined(DIAB_COMPILER)
#define INLINE /* only pragmas supported, don't bother */
#else
#define INLINE static __inline__ /* GNU c style */
#endif

#define MAGIC_START_NUMBER 0x8E4E8C4E
#define MAGIC_END_NUMBER   0x9A967D2D



#define IsValidHandle(TYPE, POINT) \
        ((MAGIC_START_NUMBER == ((TYPE *)POINT)->m_uMagicnumberStart) \
        && (MAGIC_END_NUMBER == ((TYPE *)POINT)->m_uMagicnumberEnd))

EXTERN_C Aura_Int32 GetFdZero(void);
EXTERN_C Aura_PVoid AnonymousMmap( Aura_PVoid start,
                                   Aura_UInt32 size,
                                   Aura_Int32 prot,
                                   Aura_Int32 flags );
EXTERN_C Aura_Int32 AnonymousMunmap( Aura_PVoid start, Aura_UInt32 size);

EXTERN Aura_ECode _CreateLock(/* [out] */ Aura_Handle * phLcok);
EXTERN Aura_ECode _Lock(/* [in]  */ Aura_Handle hLcok);
EXTERN Aura_ECode _Unlock(/* [in]  */ Aura_Handle hLcok);
EXTERN Aura_ECode _DestroyLock(/* [in]  */ Aura_Handle hLcok);


#define CreateLock(pHandle) \
        _CreateLock(pHandle)

#define DestroyLock(Handle) \
        _DestroyLock(Handle)

#define Lock(Handle) \
        _Lock(Handle)

#define Unlock(Handle) \
        _Unlock(Handle)


#define _PAGE_SIZE          (1u << 12)
#define IS_PAGE_ALIGNED(va) (0 == ((va) & (_PAGE_SIZE -1)))

#ifdef _GNUC
#define Aura_DebugBreak()    do { __asm("int $3"); } while(0)
#elif defined(_MSVC)
#define Aura_DebugBreak()    do { __asm int 3 } while(0)
#endif // _x86

#ifndef assert
#define assert(exp) \
                    do { \
                        if (exp) { \
                            (void)0; \
                        } else { \
                            Aura_DebugBreak(); \
                        } \
                     } while(0)
#endif // _DEBUG

#endif //__AURA_PLUS_H__
